define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'jkstatus/index?xjsbment_id='+$('#shebei_id').val(),
                    add_url: 'jkstatus/add',
                    // edit_url: 'jkstatus/edit',
                    // del_url: 'jkstatus/del',
                    multi_url: 'jkstatus/multi',
                    import_url: 'jkstatus/import',
                    dragsort_url: '',
                    table: 'baopolice',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                searchFormVisible:false,
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                commonSearch: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'sb_id', title: __('Sb_id'), operate: 'LIKE',cellStyle: function (value, row, index) {
                           
                                return {css: {"color": "#red !important"}};
                           
                            return{}; 
                         }},
                      
                        {field: 'sb_type', title: __('sb_type'),searchList: $.getJSON("bjpolice/sbtype"),operate: '=',formatter: function (value,row) {
                            if(row.hasOwnProperty("xjsbsbtype")&&row.xjsbsbtype){
                                if(row.xjsbsbtype.hasOwnProperty("title")&&row.xjsbsbtype.title){
                                    return row.xjsbsbtype.title;
                                }
                            }
                        }},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')},formatter: function (value,row) {
                          
                                return "<span style=\"color:red\">业务报警</span>";
                         
                        }},

                        {field: 'xj_laiyuan', title: __('Xj_laiyuan'), operate: 'LIKE'},
                            {field: 'admin_id', title: __('admin_id'), searchList: $.getJSON("bjpolice/admin"), operate: '=',formatter: function (value,row) {if(row.hasOwnProperty("admin")&&row.admin) {
                                if (row.admin.hasOwnProperty("nickname") && row.admin.nickname) {
                                    return row.admin.nickname;
                                }
                            }
                        },
                    },
                       
                        {field: 'bumen_id', title: __('Bumen_id'), searchList: $.getJSON("bjpolice/qrganization"), operate: '=',formatter: function (value,row) {if(row.hasOwnProperty("qrganization")&&row.qrganization) {
                            if (row.qrganization.hasOwnProperty("name") && row.qrganization.name) {
                                return row.qrganization.name;
                            }
                        }
                    },
                },
                        {field: 'key', title: __('Key'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'weigh', title: __('Weigh'), operate: false},
                     
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});